@extends('layouts.tankuang')

@section('content')
        <form name="add_form" id="add_form" action="{{url('admin/units/add')}}" method="post" enctype="multipart/form-data">
            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <div id="div_print">
                <h2 class="text-center mg_b36 mg_t25" style="font-weight: bold;">保安公司基本情况登记表</h2>
                <table class="table-form table-border w mg-auto">
                    <tbody>
                    <tr>
                        <td class="font-bd" align="center">公司名称</td>
                        <td colspan="5"><input type="text" class="form-input w easyui-validatebox" value="{{$re->name}}" name="name" data-options="required:true,missingMessage:'公司名称不能为空',validateOnCreate:false,validateOnBlur:true"></td>
                        <td rowspan="5" class="text-center">
                            @if($re->pic != '')
                                <div class="example" style="width: 190px;"><img src="{{ URL::asset('/') }}{{$re->pic}}" class="img-rounded" alt="" style="width: 190px;border-radius: 0;"></div>
                            @endif
                            <div class="box_bt">
		                        <span class="img_add"><img src="{{URL::asset('/')}}css/icons/edit_add.png">修改单位图片</span>
		                        <input class="box_file" type="file" name="pic">
		                    </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">经营范围</td>
                        <td colspan="5">
                            <input type="checkbox"  value="1" name="fanwei[]" @if(in_array(1,$re->fanwei)) checked @endif>&nbsp;门卫&nbsp;&nbsp;&nbsp;
                            <input type="checkbox"  value="2" name="fanwei[]" @if(in_array(2,$re->fanwei)) checked @endif>&nbsp;巡逻&nbsp;&nbsp;&nbsp;
                            <input type="checkbox"  value="3" name="fanwei[]" @if(in_array(3,$re->fanwei)) checked @endif>&nbsp;守护&nbsp;&nbsp;&nbsp;
                            <input type="checkbox"  value="4" name="fanwei[]" @if(in_array(4,$re->fanwei)) checked @endif>&nbsp;押运&nbsp;&nbsp;&nbsp;
                            <input type="checkbox"  value="5" name="fanwei[]" @if(in_array(5,$re->fanwei)) checked @endif>&nbsp;随身护卫&nbsp;&nbsp;&nbsp;
                            <input type="checkbox"  value="6" name="fanwei[]" @if(in_array(6,$re->fanwei)) checked @endif>&nbsp;安全检查<br>
                            <input type="checkbox"  value="7" name="fanwei[]" @if(in_array(7,$re->fanwei)) checked @endif>&nbsp;安全技术防范&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="checkbox"  value="8" name="fanwei[]" @if(in_array(8,$re->fanwei)) checked @endif>&nbsp;安全风险评估&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="checkbox"  value="9" name="fanwei[]" @if(in_array(9,$re->fanwei)) checked @endif>&nbsp;区域秩序维护
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">原市、区、派出所</td>
                        <td colspan="5"><input type="text" class="form-input w" value="{{getValue($re->city,'area','id','name')}}{{getValue($re->area,'area','id','name')}}{{getValue($re->org_id,'area','id','name')}}" disabled></td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">市、区、派出所</td>
                        <td colspan="5">
                            <div class="col-sm-3" style="margin-left: -15px;">
                                <select id="city" name="city" class="w150 input_all" style="width: 120px;">
                                    <option value="">请选择</option>
                                    @foreach($city as $v)
                                        <option value="{{$v->id}}">{{$v->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-sm-3">
                                <select id="area" name="area" class="w150 input_all" style="width: 120px;">
                                    <option value="">请选择</option>
                                </select>
                            </div>
                            <div class="col-sm-3">
                                <select id="org_id" name="org_id" class="w150 input_all" style="width: 120px;">
                                    <option value="">请选择</option>
                                </select>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">详细地址</td>
                        <td colspan="2"><input type="text" class="form-input easyui-validatebox"  value="{{$re->address}}" name="address" data-options="required:true,missingMessage:'详细地址不能为空',validateOnCreate:false,validateOnBlur:true"></td>
                        <td class="font-bd" align="center">公司住所面积</td>
                        <td><input type="text" class="form-input"  value="{{$re->mianji}}" name="mianji"></td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">企业性质</td>
                        <td colspan="2">
                            <input type="text" class="form-input" value="{{$re->xingzhi}}" name="xingzhi">
                        </td>
                        <td class="font-bd" align="center">注册资金</td>
                        <td>
                            <input type="text" class="form-input" value="{{$re->gdzc}}" name="gdzc">（万元）
                        </td>
                        <td class="font-bd" align="center">保安员人数</td>
                        <td>
                            <input type="text" class="form-input easyui-validatebox" value="{{$re->baoan_num_of_peo}}" name="baoan_num_of_peo" data-options="required:true,missingMessage:'保安员人数不能为空',validateOnCreate:false,validateOnBlur:true">
                        </td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center">股东数</td>
                        <td colspan="2">
                            {{$gudong_count}}
                        </td>
                        <td class="font-bd" align="center">联系人</td>
                        <td>
                            <input type="text" class="form-input easyui-validatebox" value="{{$re->lianxiren}}" name="lianxiren" data-options="required:true,missingMessage:'联系人不能为空',validateOnCreate:false,validateOnBlur:true">
                        </td>
                        <td class="font-bd" align="center">联系电话</td>
                        <td>
                            <input type="text" class="form-input easyui-validatebox" value="{{$re->phone}}" name="phone" data-options="required:true,validType:'phoneAndMobile',missingMessage:'联系电话不能为空',invalidMessage:'请输入正确的联系电话',validateOnCreate:false,validateOnBlur:true">
                        </td>
                    </tr>

                    @if($gudong_count)
                        <tr>
                            <td class="font-bd" align="center" rowspan="{{$gudong_count+1}}">主要股东</td>
                            <td class="font-bd" align="center">姓名</td>
                            <td class="font-bd" align="center">性别</td>
                            <td class="font-bd" align="center" colspan="2">证件号码</td>
                            <td class="font-bd" align="center">出资金额</td>
                            <td class="font-bd" align="center">出资比例</td>
                        </tr>

                        @foreach($gudong as $k=>$v)
                            <tr>
                                <td class="font-bd" align="center">{{$v->name}}</td>
                                <td class="font-bd" align="center">{{$v->sex}}</td>
                                <td class="font-bd" align="center" colspan="2">{{$v->id_number}}</td>
                                <td class="font-bd" align="center">{{$v->jine}}</td>
                                <td class="font-bd" align="center">{{$v->bili}}</td>
                            </tr>
                        @endforeach
                    @endif

                    @if($guanli_count)
                        <tr>
                            <td class="font-bd" align="center" rowspan="{{$guanli_count+1}}">主要管理人员</td>
                            <td class="font-bd" align="center">姓名</td>
                            <td class="font-bd" align="center">性别</td>
                            <td class="font-bd" align="center">文化程度</td>
                            <td class="font-bd" align="center">职务</td>
                            <td class="font-bd" align="center">身份证号码</td>
                            <td class="font-bd" align="center">联系电话</td>
                        </tr>
                        @foreach($guanli as $k=>$v)
                        <tr>
                            <td class="font-bd" align="center">{{$v->name}}</td>
                            <td class="font-bd" align="center">{{$v->sex}}</td>
                            <td class="font-bd" align="center">{{$v->education}}</td>
                            <td class="font-bd" align="center">{{$v->position}}</td>
                            <td class="font-bd" align="center">{{$v->id_number}}</td>
                            <td class="font-bd" align="center">{{$v->phone}}</td>
                        </tr>
                        @endforeach
                    @endif

                    <tr>
                        <td class="font-bd" align="center" rowspan="2">从事武装守护押运服务人员设备情况</td>
                        <td class="font-bd" align="center">守护押运人数</td>
                        <td class="font-bd" align="center">枪支型号及数量</td>
                        <td class="font-bd" align="center">子弹数量</td>
                        <td class="font-bd" align="center">押运专用车辆数</td>
                        <td class="font-bd" align="center">通讯设备型号及数量</td>
                        <td class="font-bd" align="center">报警设备型号及数量</td>
                    </tr>
                    <tr>
                        <td class="font-bd" align="center"><textarea name="yayunrenshu" class="textarea">{{$re->yayunrenshu}}</textarea></td>
                        <td class="font-bd" align="center"><textarea name="qiangzhi" class="textarea">{{$re->qiangzhi}}</textarea></td>
                        <td class="font-bd" align="center"><textarea name="zidan" class="textarea">{{$re->zidan}}</textarea></td>
                        <td class="font-bd" align="center"><textarea name="yayunche" class="textarea">{{$re->yayunche}}</textarea></td>
                        <td class="font-bd" align="center"><textarea name="tongxun" class="textarea">{{$re->tongxun}}</textarea></td>
                        <td class="font-bd" align="center"><textarea name="baojing" class="textarea">{{$re->baojing}}</textarea></td>
                    </tr>
                    </tbody>
                </table>

                {{--<div class="w1000 wbt mg_t25 mg_b18">
                    <span class="font-bd">填报单位：</span>
                    <input type="text" class="w250 input_bottom dsp" name="tbdw">
                    <span class="itv"></span>
                    <span class="font-bd">填报人：</span>
                    <input type="text" class="w250 input_bottom dsp" name="tbr">
                </div>--}}

                <div class="w wbt mg_t25 pd_b20 text-center">
                    <button id="go" type="button" class="easyui-linkbutton dsp" data-options="iconCls:'icon-save'">确定</button>
                    <a href="{{url('admin/baoan/print_baoangongsi',$id)}}" target="_blank" id="goToPageB" class="easyui-linkbutton dsp print" data-options="iconCls:'icon-print'">打印</a>
                    <button type="button" class="easyui-linkbutton dsp" data-options="iconCls:'icon-no'" onclick="$('#w').window('close')">关闭</button>
                </div>
            </div>
        </form>



        <script type="text/javascript">


            $(document).on("change",'#city', function(){
                $('#area option:gt(0)').remove();
                $('#org_id option:gt(0)').remove();
                //alert(1);die;
                var cid = $("#city").val();
                var url = "{{url('admin/getArea')}}";
                $.getJSON(url,{cid:cid},function(json){
                    /*清空原有的选项*/
                    if(json != ''){
                        $.each(json,function(index,array){
                            var option = "<option value='"+array['id']+"'";
                            option += ">"+array['name']+"</option>";
                            $("#area").append(option);
                        });
                    }
                });
            });

            $(document).on("change",'#area', function(){
                $('#org_id option:gt(0)').remove();
                var cid = $("#area").val();
                var url = "{{url('admin/getArea')}}";
                $.getJSON(url,{cid:cid},function(json){
                    /*清空原有的选项*/
                    if(json != ''){
                        $.each(json,function(index,array){
                            var option = "<option value='"+array['id']+"'";
                            option += ">"+array['name']+"</option>";
                            $("#org_id").append(option);
                        });
                    }
                });
            });
        </script>
        <script>
            $('#go').click(function (){
            	if(!$("#add_form").form('validate')){
				return false;
				}
                var formData = new FormData($("#add_form")[0]);
                $.ajax({
                    type: "POST",
                    url: "{{url('admin/baoan/edit',$id)}}",
                    data: formData,
                    async: false,
                    cache: false,
                    contentType: false,
                    processData: false,
                    success: function(data) {
                        if(data.status == 1){
                            $.messager.alert('信息提示',data.msg,'info');
                            $('#w').dialog('close');
                            $('.pagination-load').click();
                        }else {
                            $.messager.alert('信息提示',data.msg,'info');
                        }
                    }
                });
            });
        </script>
@stop